home *** CD-ROM | disk | FTP | other *** search
- class Player extends MovieClip
- {
- var v;
- var snd;
- var ts;
- var track;
- var z;
- var head;
- var a = 0;
- var d = 0;
- var ps = 0;
- var va = 0;
- var rv = 0;
- var sndOff = false;
- static var iv = 10;
- static var g = 1;
- static var f = 0.995;
- static var lc = 0.000033333333333333335;
- static var cfc = 8900;
- static var rs = 0.5;
- static var rd = 0.93;
- static var gc = 0.56;
- function Player()
- {
- super();
- this.v = new Vector(0,0);
- this.ps = Player.iv;
- this.snd = new Sound(this);
- this.snd.attachSound("movement");
- if(!_root.brdcst)
- {
- _root.brdcst = {};
- AsBroadcaster.initialize(_root.brdcst);
- }
- _root.brdcst.addListener(this);
- if(this._parent.sndOff)
- {
- this.sndOff = true;
- }
- if(!this.sndOff)
- {
- this.snd.start(0,999999999);
- this.snd.setVolume(0);
- }
- }
- function sndChange(t)
- {
- if(t)
- {
- this.snd.stop();
- }
- else
- {
- this.snd.start(0,999999999);
- }
- }
- function move(ftime, ia)
- {
- var _loc8_ = this.track.getHeightAt(this.ts,this.d + 1);
- var _loc6_ = Math.atan2(_loc8_ - this.z,1);
- this.va = - Math.sin(_loc6_);
- this.ps += this.va * Player.g;
- if(!this.ts.s)
- {
- var _loc9_ = Math.sqrt(Math.abs(this._rotation - ia));
- }
- else
- {
- _loc9_ = 0;
- }
- this.ps *= 1 - Player.lc * _loc9_ * ftime;
- this.ps *= Player.f;
- this.ps = this.ps <= Vars.tVel ? this.ps : Vars.tVel;
- this.snd.setVolume(this.ps / Vars.tVel * 100);
- var _loc4_ = this.ps / 1000;
- var _loc7_ = this.ps / 1000 * ftime;
- this.d += _loc7_;
- var _loc3_ = this.track.length;
- var _loc2_ = 0;
- while(_loc2_ < _loc3_)
- {
- if(this.track[_loc2_].tl + this.track[_loc2_].l > this.d)
- {
- break;
- }
- if(this.track[_loc2_] == undefined)
- {
- this.raceEnded();
- return 0;
- }
- this.track.shift();
- _loc2_ = _loc2_ - 1;
- _loc2_ = _loc2_ + 1;
- }
- this.ts = this.track[_loc2_];
- if(Key.isDown(39))
- {
- this.rv -= Player.rs;
- }
- if(Key.isDown(37))
- {
- this.rv += Player.rs;
- }
- this.rv -= Player.gc * Math.sin(this._rotation * Trig.dr);
- §§push(Key.isDown(39) && !Key.isDown(37) ? this.gotoAndStop("tiltRight") : (Key.isDown(37) && !Key.isDown(39) ? this.gotoAndStop("tiltLeft") : this.gotoAndStop("flat")));
- if(!this.ts.s)
- {
- this.rv += _loc4_ * _loc4_ * Player.cfc / this.ts.r * this.ts.d;
- }
- this.rv *= Player.rd;
- this._rotation += this.rv * 0.03 * ftime;
- this.head._rotation = - this._rotation / 2;
- var _loc5_ = this.d - this.ts.tl;
- if(this.ts.s)
- {
- this.v.x = this.ts.x + _loc5_ * Math.cos(this.ts.a);
- this.v.y = this.ts.y + _loc5_ * Math.sin(this.ts.a);
- this.a = this.ts.a;
- }
- else
- {
- this.a = _loc5_ / this.ts.r * this.ts.d + this.ts.a - Trig.ra * this.ts.d;
- this.v.x = this.ts.cx + this.ts.r * Math.cos(this.a);
- this.v.y = this.ts.cy + this.ts.r * Math.sin(this.a);
- this.a += Trig.ra * this.ts.d;
- }
- this.z = this.track.getHeightAt(this.ts,this.d);
- return _loc4_;
- }
- function raceEnded()
- {
- this._parent.brdcst.broadcastMessage("endRace");
- this._parent.times.t = this._parent.time;
- this.snd.stop();
- delete this.snd;
- this._parent.messages.gotoAndStop(1);
- this._parent.warning_signs.gotoAndStop(1);
- this._parent.messages._visible = false;
- this._parent.gotoAndStop("endRace");
- }
- }
-